From 0aa64d6b2326028d9cc7d2540d466bc251483c0f Mon Sep 17 00:00:00 2001 From: robertl Date: Sat, 17 Jan 2004 17:38:48 +0000 Subject: [PATCH] Add bounding box code. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@656 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/waypt.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gpsbabel/waypt.c b/gpsbabel/waypt.c index 51c7f0f90..a3a85db5f 100644 --- a/gpsbabel/waypt.c +++ b/gpsbabel/waypt.c @@ -153,6 +153,36 @@ waypt_disp_all(waypt_cb cb) } } +/* + * Makes another pass over the data to compute bounding + * box data and populates bounding box information. + */ + +void +waypt_compute_bounds(bounds *bounds) +{ + queue *elem, *tmp; + waypoint *waypointp; + + /* Set data out of bounds so that even one waypoint will reset */ + bounds->max_lat = -9999; + bounds->max_lon = -9999; + bounds->min_lat = 9999; + bounds->min_lon = 9999; + + QUEUE_FOR_EACH(&waypt_head, elem, tmp) { + waypointp = (waypoint *) elem; + if (waypointp->latitude > bounds->max_lat) + bounds->max_lat = waypointp->latitude; + if (waypointp->longitude > bounds->max_lon) + bounds->max_lon = waypointp->longitude; + if (waypointp->latitude < bounds->min_lat) + bounds->min_lat = waypointp->latitude; + if (waypointp->longitude < bounds->min_lon) + bounds->min_lon = waypointp->longitude; + } +} + waypoint * find_waypt_by_name(const char *name) { -- 2.30.2